package com.friend.chat.page.view.main

import com.friend.chat.base.BaseFragment
import com.friend.chat.databinding.FragmentMeBinding
import com.friend.chat.page.bean.UserBean
import com.friend.chat.page.view.register.LoginActivity
import com.friend.chat.page.vm.MainViewModel
import com.friend.chat.utils.GlideUtils
import com.friend.chat.utils.SPUtils

/**
 * @des
 * @author batie fancy
 * @date 2023/1/8
 */
class MeFragment :BaseFragment<FragmentMeBinding,MainViewModel>() {
    override fun yourViewModel(): MainViewModel = MainViewModel()

    override fun yourViewBing(): FragmentMeBinding {
       return FragmentMeBinding.inflate(layoutInflater)
    }

    override fun init() {
        val userBean = SPUtils.getInstance().getObject("user") as UserBean
        GlideUtils.loadRadiusImg1(mViewBing.ivMeHeader,userBean.header,4)
        mViewBing.tvMeNickname.text = userBean.username
        mViewBing.tvMeId.text = "麦信号: ${userBean.uid}"


        mViewBing.tvExit.setOnClickListener {
            SPUtils.getInstance().clear()
            activity?.finish()
            LoginActivity.open(requireActivity())
        }
    }
}